import { StringIterator } from "lodash";
import { MapLocation } from "/@/api/models";
import { AiotSubApp } from "/@/base/data";

export interface ProjectItem {
  contactPerson?: string;
  contactPhone?: string;
  coverPhoto?: string;
  projectLogo?: string;
  createdOn?: string;
  customerId?: string;
  customerName?: string;
  industryId?: string;
  industryName?: string;
  location?: MapLocation;
  locations?: MapLocation;
  projectId?: string;
  projectName?: string;
  region?: string;
  introduction?: string;
  livePhotosList?: string[];
  livePhotos?: string[];
  regionId?: string;
  projectLeaderUserName?: string;
  projectTransactorUserName?: string;
  projectLeaderUserId?: string;
  projectTransactorUserId?: string;
  projectLeaderUserPhone?: string;
  projectTransactorUserPhone?: string;
  _projectLeaderUserName?: string;
  _projectTransactorUserName?: string;
  operationDate?: string;
  designUnitName?: string;
  buildingArea?: number | string;
  country?: string;
  address?: string;
  _address?: string;
  regionName?: string;
  regionCode?: string;
  projectInfoId?: string;
  projectMembers?: Array<ProjectMemberItem>;
}
export interface ProjectInfo {
  buildingArea?: number | string;
  coverPhoto?: string;
  designUnitName?: string;
  introduction?: string;
  livePhotosList?: string[];
  livePhotos?: string[];
  operationDate?: string;
  additionalInfo?: string;
  projectLogo?: string;
  projectInfoId?: string;
}
export interface ReqProjectInfo {
  address?: string;
  contactPerson?: string;
  contactPhone?: string;
  customerId?: string;
  customerName?: string;
  industryId?: string;
  industryName?: string;
  projectLeaderUserName?: string;
  projectLeaderUserPhone?: string;
  projectTransactorUserName?: string;
  projectTransactorUserPhone?: string;
  projectLeaderUserId?: string;
  projectTransactorUserId?: string;
  _projectLeaderUserName?: string;
  _projectTransactorUserName?: string;
  location?: {
    latitude?: string;
    longitude?: string;
  };
  projectInfo?: ProjectInfo | null;
  projectName?: string;
  projectPermissionOrganizations?: {
    organizationId?: string;
  }[];
  projectPermissionScope?: string;
  regionName?: string;
  regionId?: string;
  projectId?: string;
  projectInfoId?: string;
  projectMembers?: Array<ProjectMemberItem>;
  equipmentSummary?: {
    equipmentSummary: number;
    equipmentOnlineCnt: number;
    equipmentTotal: number;
    getEquipmentFaultCnt: number;
  };
  weatherQueryResp?: {
    adcode: string;
    city: string;
    humidity: string;
    province: string;
    reporttime: string;
    temperature: string;
    weather: string;
    winddirection: string;
    windpower: string;
  };
}
export interface ReqProject {
  projectId: string;
}

export interface ProjectBaseInfo {
  projectName?: string;
  industryId?: string;
  country?: string;
  address?: string;
  _address?: string;
  location: {
    latitude?: string;
    longitude?: string;
  };
  regionId: string;
}
export enum MemberType {
  CREATER = "创建者",
  LEADER = "项目主管",
  MEMBER = "运维工程师",
}
export interface ProjectUser {
  memberType: string;
  memberTypeName: string;
  organizationId: string;
  organizationName: string;
  projectId: string;
  projectMemberId: string;
  projectName: string;
  state: string;
  userId: string;
  userName: string;
  stateName: string;
}

export interface OperationUserSearchReq {
  projectId?: string;
  projectRoleId?: string;
  searchText?: string;
}

export interface ProjectUserReq {
  organizationId?: string;
  projectId: string;
  searchText?: string;
}

export enum TimeType {
  DAY = "D",
  MONTH = "M",
  QUARTER = "QUARTER",
  YEAR = "Y",
  HOUR = "HOUR",
}

export interface CategoryTable {
  deviceName: string;
  position: string;
  deviceCode: string;
  brandName: string;
  deviceState: string;
}
export interface CategoryTableProps {
  categoryName: string;
  categoryNum: number;
  tableData: Array<CategoryTable>;
}

export interface EquipmentSummaryItem {
  equipmentAlarm: number;
  equipmentDanger: number;
  equipmentFault: number;
  equipmentOffline: number;
  equipmentOnline: number;
  equipmentTotal: number;
  equipmentWarning: number;
  faultPercentage: string;
  offlinePercentage: string;
  onlinePercentage: string;
}
export type PartialEquipmentSummaryItem = Partial<EquipmentSummaryItem>;

export interface EquipmentSummaryReq {
  isCustomer: boolean;
  userId: string;
  projectId?: string;
}

export interface EnergySummary {
  projectId: string;
  period: "D" | "Y" | "M" | "H";
  endTime?: string;
  sectionKey?: string;
  startTime?: string;
}

export interface LineChartModal {
  category?: string[];
  xAxis?: string[];
  yAxis?: any; // key不确定，只能any
  nodes?: { name: string; itemStyle: { color: string } };
  links?: { source: string; target: string; value: number };
}
export interface SankeyItem {
  category?: string[];
  xAxis?: string[];
  yAxis?: any; // key不确定，只能any
  nodes?: { name: string; itemStyle: { color: string } };
  links?: { source: string; target: string; value: number }[];
}
export interface SummaryItems {
  momRatio: string;
  momState: number;
  type: number;
  value: string;
  yoyRatio: string;
  yoyState: number;
}
export interface LineTrendItem {
  currentPeriodTrend: Array<string>;
  periods: Array<string>;
  previousPeriodTrend: Array<string>;
}
export interface DrainageCapacityItem {
  xData: Array<string>;
  flowYData: Array<number>;
  flwaterYData: Array<number>;
}
export interface EnergyTrendsItem {
  electricityOfHvacTrends: LineTrendItem;
  electricityTrends: LineTrendItem;
  photovoltaicsTrends: LineTrendItem;
  waterTrends: LineTrendItem;
}

export interface SectionItem {
  sectionKey: string;
  sectionName: string;
}
export interface TrendsItem {
  electricityValue: number;
  period: string;
  waterValue: number;
}
export interface TrendsSectionItem {
  electricityTotal: number;
  energySectionTrend: Array<TrendsItem>;
  waterTotal: number;
}

export interface SectionBarItem {
  key: string;
  name: string;
  value: string;
}

export type UserLabel = "LEADER" | "TRANSACTOR" | "CREATOR" | "CONTACTS" | "NONE" | null | "";

export interface ProjectMemberItem {
  projectMemberType?: string;
  projectRoleId?: string;
  userId?: string;
  userLabel?: UserLabel;
  userLabelName?: string;
  userLabelNameArr?: string[];
  userName?: string;
  companyPhone?: string;
  memberType?: "MEMBER" | "LEADER";
  organizationId?: string;
  organizationName?: string;
  projectId?: string;
  projectMemberId?: string;
  projectRoleName?: string;
  state?: string;
  stateName?: string;
  applicationPermissions?: AiotSubApp[];
}

export interface ProjectRoleItem {
  projectRoleId?: string;
  projectRoleName?: string;
}

export interface CustomAttributesItem {
  customLabel?: string;
  customValue?: string;
}
export interface ProjectDetailInfo {
  memberList?: Array<ProjectMemberItem>;
  project?: ReqProjectInfo;
}

export interface ConditionsItem {
  equipmentCategoryList: { id: string; name: string }[];
  equipmentStateList: { id: string; name: string }[];
  equipmentTypeList: { id: string; name: string }[];
  projectList: { id: string; name: string }[];
}

export interface MyProjectItem {
  projectId: string;
  projectMemberCount: number;
  projectName: string;
  projectMembersList: ProjectMemberItem[];
  projectLogo: string;
}

export interface ExtrendData {
  periods?: Array<string>;
  currentPeriodTrend?: Array<number>;
  previousPeriodTrend?: Array<number>;
}
